home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SAMPLES.BIN / ThreadX.java < prev    next >
Encoding:
Java Source  |  1996-12-07  |  5.5 KB  |  204 lines

  1. /*
  2.     A basic extension of the java.applet.Applet class
  3.  */
  4.  
  5. import java.awt.*;
  6. import java.applet.*;
  7.  
  8. public class ThreadX extends Applet {
  9.     void stop3_Clicked(Event event) {
  10.         pa3.stop();
  11.     }
  12.  
  13.     void start3_Clicked(Event event) {
  14.         pa3.resume();
  15.     }
  16.  
  17.     void stop2_Clicked(Event event) {
  18.         pa2.stop();
  19.     }
  20.  
  21.     void start2_Clicked(Event event) {
  22.         pa2.resume();
  23.     }
  24.  
  25.     void stop1_Clicked(Event event) {
  26.         pa1.stop();
  27.     }
  28.  
  29.     void start1_Clicked(Event event) {
  30.         pa1.resume();
  31.     }
  32.  
  33.     void resetButton_Clicked(Event event) {
  34.         stopButton_Clicked(null);
  35.         pa1.reset();
  36.         pa2.reset();
  37.         pa3.reset();
  38.         pa1.repaint();
  39.         pa2.repaint();
  40.         pa3.repaint();
  41.     }
  42.  
  43.     void stopButton_Clicked(Event event) {
  44.         pa1.stop();
  45.         pa2.stop();
  46.         pa3.stop();
  47.     }
  48.  
  49.     void startButton_Clicked(Event event) {
  50.         pa1.resume();
  51.         pa2.resume();
  52.         pa3.resume();
  53.     }
  54.  
  55.  
  56.     public void init() {
  57.         super.init();
  58.  
  59.         // Take out this line if you don't use symantec.itools.net.RelativeURL
  60.         symantec.itools.lang.Context.setDocumentBase(getDocumentBase());
  61.  
  62.         //{{INIT_CONTROLS
  63.         setLayout(new BorderLayout(0,0));
  64.         addNotify();
  65.         resize(505,293);
  66.         mainButtonPanel = new java.awt.Panel();
  67.         mainButtonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,20,10));
  68.         mainButtonPanel.reshape(0,262,505,31);
  69.         add("South", mainButtonPanel);
  70.         startButton = new java.awt.Button("All Start");
  71.         startButton.reshape(165,5,59,21);
  72.         mainButtonPanel.add(startButton);
  73.         stopButton = new java.awt.Button("All Stop");
  74.         stopButton.reshape(229,5,58,21);
  75.         mainButtonPanel.add(stopButton);
  76.         resetButton = new java.awt.Button("Reset");
  77.         resetButton.reshape(292,5,51,21);
  78.         mainButtonPanel.add(resetButton);
  79.         animationArea = new java.awt.Panel();
  80.         animationArea.setLayout(new GridLayout(1,3,0,0));
  81.         animationArea.reshape(0,0,505,262);
  82.         add("Center", animationArea);
  83.         aPanel1 = new java.awt.Panel();
  84.         aPanel1.setLayout(new BorderLayout(0,0));
  85.         aPanel1.reshape(0,0,168,262);
  86.         aPanel1.setBackground(new Color(16711680));
  87.         animationArea.add(aPanel1);
  88.         ap1 = new java.awt.Panel();
  89.         ap1.setLayout(new FlowLayout(FlowLayout.CENTER,5,25));
  90.         ap1.reshape(0,0,168,231);
  91.         aPanel1.add("Center", ap1);
  92.         subP1 = new java.awt.Panel();
  93.         subP1.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  94.         subP1.reshape(0,231,168,31);
  95.         aPanel1.add("South", subP1);
  96.         start1 = new java.awt.Button("Start");
  97.         start1.reshape(41,5,41,21);
  98.         subP1.add(start1);
  99.         stop1 = new java.awt.Button("Stop");
  100.         stop1.reshape(87,5,40,21);
  101.         subP1.add(stop1);
  102.         aPanel2 = new java.awt.Panel();
  103.         aPanel2.setLayout(new BorderLayout(0,0));
  104.         aPanel2.reshape(168,0,168,262);
  105.         animationArea.add(aPanel2);
  106.         ap2 = new java.awt.Panel();
  107.         ap2.setLayout(new FlowLayout(FlowLayout.CENTER,5,25));
  108.         ap2.reshape(0,0,168,231);
  109.         aPanel2.add("Center", ap2);
  110.         subP2 = new java.awt.Panel();
  111.         subP2.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  112.         subP2.reshape(0,231,168,31);
  113.         aPanel2.add("South", subP2);
  114.         start2 = new java.awt.Button("Start");
  115.         start2.reshape(41,5,41,21);
  116.         subP2.add(start2);
  117.         stop2 = new java.awt.Button("Stop");
  118.         stop2.reshape(87,5,40,21);
  119.         subP2.add(stop2);
  120.         aPanel3 = new java.awt.Panel();
  121.         aPanel3.setLayout(new BorderLayout(0,0));
  122.         aPanel3.reshape(336,0,168,262);
  123.         aPanel3.setBackground(new Color(255));
  124.         animationArea.add(aPanel3);
  125.         ap3 = new java.awt.Panel();
  126.         ap3.setLayout(new FlowLayout(FlowLayout.CENTER,5,25));
  127.         ap3.reshape(0,0,168,231);
  128.         aPanel3.add("Center", ap3);
  129.         subP3 = new java.awt.Panel();
  130.         subP3.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  131.         subP3.reshape(0,231,168,31);
  132.         aPanel3.add("South", subP3);
  133.         start3 = new java.awt.Button("Start");
  134.         start3.reshape(41,5,41,21);
  135.         subP3.add(start3);
  136.         stop3 = new java.awt.Button("Stop");
  137.         stop3.reshape(87,5,40,21);
  138.         subP3.add(stop3);
  139.         //}}
  140.  
  141.         ap1.add(pa1);
  142.         ap2.add(pa2);
  143.         ap3.add(pa3);
  144.     }
  145.  
  146.     public boolean handleEvent(Event event) {
  147.         if (event.target == startButton && event.id == Event.ACTION_EVENT) {
  148.             startButton_Clicked(event);
  149.         }
  150.         if (event.target == stopButton && event.id == Event.ACTION_EVENT) {
  151.             stopButton_Clicked(event);
  152.         }
  153.         if (event.target == resetButton && event.id == Event.ACTION_EVENT) {
  154.             resetButton_Clicked(event);
  155.         }
  156.         if (event.target == start1 && event.id == Event.ACTION_EVENT) {
  157.             start1_Clicked(event);
  158.         }
  159.         if (event.target == stop1 && event.id == Event.ACTION_EVENT) {
  160.             stop1_Clicked(event);
  161.         }
  162.         if (event.target == start2 && event.id == Event.ACTION_EVENT) {
  163.             start2_Clicked(event);
  164.         }
  165.         if (event.target == stop2 && event.id == Event.ACTION_EVENT) {
  166.             stop2_Clicked(event);
  167.         }
  168.         if (event.target == start3 && event.id == Event.ACTION_EVENT) {
  169.             start3_Clicked(event);
  170.         }
  171.         if (event.target == stop3 && event.id == Event.ACTION_EVENT) {
  172.             stop3_Clicked(event);
  173.         }
  174.         return super.handleEvent(event);
  175.     }
  176.  
  177.     //{{DECLARE_CONTROLS
  178.     java.awt.Panel mainButtonPanel;
  179.     java.awt.Button startButton;
  180.     java.awt.Button stopButton;
  181.     java.awt.Button resetButton;
  182.     java.awt.Panel animationArea;
  183.     java.awt.Panel aPanel1;
  184.     java.awt.Panel ap1;
  185.     java.awt.Panel subP1;
  186.     java.awt.Button start1;
  187.     java.awt.Button stop1;
  188.     java.awt.Panel aPanel2;
  189.     java.awt.Panel ap2;
  190.     java.awt.Panel subP2;
  191.     java.awt.Button start2;
  192.     java.awt.Button stop2;
  193.     java.awt.Panel aPanel3;
  194.     java.awt.Panel ap3;
  195.     java.awt.Panel subP3;
  196.     java.awt.Button start3;
  197.     java.awt.Button stop3;
  198.     //}}
  199.  
  200.     PolygonAnimation pa1 = new PolygonAnimation(100);
  201.     PolygonAnimation pa2 = new PolygonAnimation(120);
  202.     PolygonAnimation pa3 = new PolygonAnimation(150);
  203. }
  204.